home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000135_icon-group-sender _Tue Jun 15 16:21:59 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id QAA12496
for icon-group-addresses; Tue, 15 Jun 1999 16:20:36 -0700 (MST)
Message-Id: <199906152320.QAA12496@baskerville.CS.Arizona.EDU>
Delivered-To: icon-group@silliac.cs.arizona.edu
Date: Tue, 15 Jun 1999 16:41:16 -0300 (ADT)
From: Larry Bezeau <bezeau@unb.ca>
X-Sender: bezeau@sol.sun.csd.unb.ca
To: Icon list <icon-group@optima.CS.Arizona.EDU>
Subject: Problems with noncase.icn from program library
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
I have recently been using the Icon program library for
dealing with strings using regular expressions and have run into
a few problems, not with the regular expression procedures
themselves, but with a set of procedures called "noncase.icn",
used for case insensitive searching with regular expressions.
An example follows.
The following procedure from noncase.icn is intended to
duplicate find in a case insensitive way.
procedure c_find(s1,s2,i1,i2)
local scanPos,endPos
scanPos := match("",s2,i1,i2)
endPos := many(&cset,s2,i1,i2)
suspend scanPos - 1 + find(map(s1),
map((if \s2 then s2 else &subject)[scanPos:endPos]))
end
A problem occurs if the subject string is empty. In this case,
the statement to set the value of endPos fails leaving endPos
undefined. The last statement produces a program error when
an attempt is made to extract a substring of &subject with
one index having the null value. The analogous built-in function
(find) simply fails under the same circumstances.
My solution was to replace the fourth line in the procedure
with
endPos := (many(&cset,s2,i1,i2) | scanPos)
which at least prevents the program error. I have not tested this
rigorously. Can anyone see problems with this or make other
suggestions?
Larry Bezeau@UNB.Ca